<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Stimulus360.Controllers.Projects.SubmitPhotoViewModel>" %>

<%@ Import Namespace="Stimulus360.Models.Cms" %>
<%@ Import Namespace="Stimulus360.Models.Data.CustomTypes" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="Stimulus360.Controllers" %>
<%@ Import Namespace="Stimulus360.Services" %>
<%@ Import Namespace="Stimulus360.Models.Data"%>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <%ProjectSummary project = Model.ProjectSummary;
      RatingViewModel ratingViewModel = new RatingViewModel
      {
          Id = project.ProjectId,
          AverageRating = project.AverageRating,
          IsDisabled = true,
          IdeaId=project.ProjectId
      }; %>
      <%Html.RenderPartial("ProjectDetailLeftNavigation", Model.ProjectSummary); %>
      <% using (Html.BeginForm("SubmitPhoto", "Projects", FormMethod.Post, new { @enctype = "multipart/form-data", @id = "PhotoUploadForm" })) 
       {%>
        <div class="mainInner colViewHdr">
            <div class="projListItem p10">
                <h1><%=project.ProjectTitle%></h1>
                <div class="projStatusBar mt10">
                    <div class="floatLeft pt02">
                        <%=project.SubmittedDate.ToString("D", CultureInfo.CreateSpecificCulture("en-US"))%> | PM: <%=project.Submitter%></div>
                    <div class="projStatus floatLeft pl10">
                        <div>
                            <%Html.RenderPartial("Rating", ratingViewModel); %>
                        </div>
                        <div class="separatorR">
                            (<%=project.UserRatingsCount%>)</div>
                        <div class="separatorR pt02">
                            Favorites <%=project.FavoritesCount %></div>
                        <div class="projStatusRpt">
                            <h4>Status:</h4>
                            <div><%= Html.Image( project.StatusString.ToLower() + ".png", "") %></div>
			                <div class="statusWdth"><%= project.StatusString %></div>
                        </div>
                        <br clear="all" />
                    </div>
                </div>
            </div>
            <br clear="all" />
            <h3>Submit Photo</h3>
            <div class="errorMessages"><%= Html.ValidationSummary(Stimulus360.Resources.Stimulus360.ValidationSummary_MandatoryDetails )%></div>
            <div class="projListItemBg">
                <div class="pb5 pt10"><strong>Title</strong></div>
                <div>
                    <%=Html.TextBox("Title", Model.Photo.Title, new { @class = "initialfocus", @tabindex = "2", @value = "", @size = "70", @maxlength = "50" })%>
                    <%= Html.ValidationMessage("Title", "*", new { @class = "requiredfield" })%>
                </div>
                <div class="pt10 pb5"><strong>Description:</strong></div>
                <div>
                    <%=Html.TextArea("Description", Model.Photo.Description, new { @cols = "70", @rows = "10", @tabindex = "3" })%>
                    <div class="pb5 pt10">
                        <strong>Select Photo to upload </strong><span class="note">Allowed Formats: (gif, jpeg, jpg ,bmp, png)</span>
                    </div>
                    <div>
                        <input type="file" name="PhotoPath" id="PhotoPath" size="40" tabindex="4" />
                        <%= Html.ValidationMessage("PhotoPath", "*", new { @class = "requiredfield" })%>
                        <%= Html.ValidationMessage("Format", "*", new { @class = "requiredfield" })%>
                    </div>
                    <br />
                    <div class="buttons">
                      <input name="submit" type="submit" class="btTxt submit" id="saveForm2" value="Upload" tabindex="5" />
                      &nbsp;
	                  <input name="Cancel" type="button" class="btTxt submit" id="cancelForm" value="Cancel" tabindex="6" />

                    </div>  
                </div>
                <br clear="all" />
            </div>
            <br clear="all" />
            <br />
        </div>
        <br clear="all" />
      <%} %>
    
    <script language="javascript" type="text/javascript">
        $(document).ready(function() {
            $(".initialfocus").focus();
            $("#photosTag").click();
            $("#cancelForm").click(function() {
                window.location.href = "/Projects/" + "<%= Model.ProjectSummary.ProjectId %>" + "/Photos";
            });

            $("#Description").keyup(function() {
                textLimit(this, 255);
            });
            $("#Description").blur(function() {
                textLimit(this, 255);
            });
            
            function textLimit(field, maxlen) {
                if (field.value.length > maxlen) {
                    while (field.value.length > maxlen) {
                        field.value = field.value.replace(/.$/, '');
                    }
                }
            }

        });
    </script>
</asp:Content>
